import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: () => import('../views/LayoutView.vue'),
      // 路由重定向
      redirect: '/home',
      // 二级路由
      children:[
        {
          path: '/home',
          name: 'home',
          component: () => import('../views/HomeView.vue'),
        },
        {
          path: '/productList',
          name: 'productList',
          component: () => import('../views/ProductList.vue')
        },
        {
          path: '/tongji',
          name: 'tongji',
          component: () => import('../views/TongjiView.vue')
        },
        {
          path: '/usermanager',
          name: 'usermanager',
          component: () => import('../views/UserManager.vue')
        },
        {
          path: '/useradd',
          name: 'useradd',
          component: () => import('../views/UserAdd.vue')
        },
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/LoginView.vue'),
    },
  ],
})

export default router
